package com.abc.recycling.mapper;

import com.abc.recycling.model.NotificationTemplate;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface NotificationTemplateMapper {
    
    @Select("SELECT * FROM notification_template WHERE id = #{id}")
    NotificationTemplate findById(@Param("id") Long id);
    
    @Select("SELECT * FROM notification_template WHERE code = #{code}")
    NotificationTemplate findByCode(@Param("code") String code);
    
    @Select("SELECT * FROM notification_template WHERE status = 1 " +
            "ORDER BY create_time DESC")
    List<NotificationTemplate> findAll();
    
    @Insert("INSERT INTO notification_template (code, name, type, title, content, variables, status, create_time, update_time) " +
            "VALUES (#{code}, #{name}, #{type}, #{title}, #{content}, #{variables}, #{status}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(NotificationTemplate template);
    
    @Update("UPDATE notification_template SET name = #{name}, type = #{type}, " +
            "title = #{title}, content = #{content}, variables = #{variables}, " +
            "status = #{status}, update_time = #{updateTime} WHERE id = #{id}")
    void update(NotificationTemplate template);
    
    @Delete("DELETE FROM notification_template WHERE id = #{id}")
    void deleteById(@Param("id") Long id);
    
    @Update("UPDATE notification_template SET status = #{status}, " +
            "update_time = #{updateTime} WHERE id = #{id}")
    void updateStatus(@Param("id") Long id, @Param("status") Integer status);
} 